<template>
	<view class="content">
		<u-navbar
			title="关于我们" 
			:bg-color="`${mainColor}`" 
			fixed 
			placeholder 
			autoBack
			:height="navigationBarHeight"
			:title-style="{color:`${textColor}`, fontSize:'16px', fontWeight:700}"
			:left-icon-color="`${textColor}`"
			v-if="showTitle"
			/>
		<scroll-view scroll-y enable-back-to-top show-scrollbar="false"
			:style="{height: `calc(100vh - ${navHeight}px)`}">
			<view class="ab_content" :style="{paddingBottom: `calc(78px + ${bottomHeight}px)`}">
				<rich-text :nodes="data.content" v-if="data.content"></rich-text>
			</view>	
		</scroll-view>
		<view class="fix-bottm" :style="{bottom:`${bottomHeight}px`}" v-if="!isAlipayPlatform">
			<u-button :custom-style="{color: `${textColor}`}" :color="`${mainColor}`" shape="circle" @click="showCooperate=true">合作咨询</u-button>
		</view>
		<u-popup mode="center" :show="showCooperate" @close="showCooperate=false"
			custom-style="border-radius: 10px;" closeable>
			<view class="tan-box">
				<view class="wx-account">
					<text class="text1">
						微信号：
					</text>
					{{data.wechat_id}}
				</view>
				<image :src="baseUrl(data.contact_qrcode)" class="qrcode"></image>
				<view class="text2">
					工作时间：
				</view>
				<view class="text2">
					{{data.work_time}}
				</view>
				<view class="text2">
					非工作时间请耐心等待
				</view>
				<view class="btn">
					<u-button :color="`${mainColor}`" :custom-style="{borderRadius: '10px', color: `${textColor}`}"
						@click="copyWechat">复制微信号</u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import { systemInfo } from '@/utils/mixin';
	import { baseUrl, getAboutus } from '@/api';

	export default {
		mixins: [systemInfo],
		data() {
			return {
				baseUrl,
				showCooperate: false,
				data: {},
				platform: undefined,
			}
		},
		onLoad() {
			this.getSystemInfo();
			this.loadDetail();
		},
		computed: {
			isAlipayPlatform() {
				return this.platform === 'MP-ALIPAY';
			}
		},
		methods: {
			async loadDetail() {
				const res = await getAboutus();
				this.data = res.data;
				
			},
			getPaddingTop(image) {
			  const ratio = (image.Height / image.width) * 100;
			   return `${ratio.toFixed(6)}%`;
			},
			copyWechat() {
				uni.setClipboardData({
				    data: this.data.wechat_id,
				    success: function () {
						uni.showToast({
							title:'复制成功',
							icon:'none'
						})
				    }
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.content {
	background-color: #fff;
	overflow: hidden;
}

.ab_content {
	padding: 20px 10px 78px;
	background-color: #fff;
}

.fix-bottm {
    position: fixed;
    bottom: 0;
	left: 0;
	right: 0;
    padding: 10px;
    box-sizing: border-box;
	background-color: #fff;
}

.tan-box {
    width: 260px;
    border-radius: 5px;
    padding: 20px;
    text-align: center;
    font-family: Times New Roman;
	
	.qrcode {
	    width: 135px;
	    height: 135px;
	    margin: 20px auto 5px;
	}
	
	.text2 {
	    font-size: 14px;
	    padding: 5px 0;
	}
	
	.btn {
	    width: 208px;
	    margin: 10px auto 0;
	}
}
</style>
